package com.tree.thrive.business.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @Auther: cheng.tang
 * @Date: 2024/10/23
 * @Description: top-tree
 */
@Component
@Slf4j
public class CustomEventRunner implements CommandLineRunner {

    private final CustomEventPublisher publisher;

    @Autowired
    public CustomEventRunner(CustomEventPublisher publisher) {
        this.publisher = publisher;
    }

    @Override
    public void run(String... args) throws Exception {
        String msg = "Hello, this is a custom event!";
        log.info(" begin to publish {} ", msg);
        publisher.publish(msg);
        log.info(" end to publish {} ", msg);
    }


}
